﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DimensionData
{
    public class DimRange01View : DimRangeView
    {
        public DimRange01View(DimRange dimRange)
            : base(dimRange)
        {
        }

        public override DataTable Pull()
        {
            DataTable table = BuildSchema(_dimRange);
            //Stack<DimData> dimStack = new Stack<DimData>();
            //for (int i = this._dims.Count - 1; i >= 0; i--)
            //{
            //    dimStack.Push(this._dims[i]); ;
            //}

            //while (dimStack.Count > 0)
            //{
            //    DimData dim = dimStack.Pop();

            //    DataRow row = table.NewRow();
            //    row["c"] = 0;
            //    row["l"] = dim.Level;
            //    row["n"] = dim.Name;
            //    table.Rows.Add(row);

            //    for (int i = dim.Children.Count - 1; i >= 0; i--)
            //    {
            //        dimStack.Push(dim.Children[i]);
            //    }
            //}

            return table;
        }

        private DataTable BuildSchema(DimRange dimRange)
        {
            DataTable table = new DataTable();

            DimRange curRange = dimRange;
            while (curRange != null)
            {
                if (curRange.Direction == DimDirection.Y)
                {
                    table.Columns.Add(string.Format("n{0}", curRange.Level));
                }
                else
                {
                }
            }

            return table;
        }
    }
}
